﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;

namespace KunLunDirModels {
	public class SerializerBuilder {
		public static  string SerilizeAnXml(object obj) {
			MemoryStream stream = new System.IO.MemoryStream();
			XmlSerializer serializer = new XmlSerializer(obj.GetType());
			serializer.Serialize(stream, obj);
			return Encoding.GetEncoding("utf-8").GetString(stream.GetBuffer());
		}

		public static object SerilizeAnObject(string xml,Type ot) {
			XmlSerializer serializer = new XmlSerializer(ot);
			System.IO.StringReader write = new StringReader(xml);
			
			return serializer.Deserialize(write);
		}
	}
}
